<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var str = 'abcdefab';
        // 将ab替换成xy
        console.log(str.replace('ab','xy'));
        console.log('1.==>',str);
        console.log(str.replace(/ab/g,'xy'));
        
        console.log('2.==>',str);
    </script>
</body>
</html>